Use attribute parser for deprecated attribute checking - #160459
Conversation
|
Some changes occurred in compiler/rustc_attr_parsing cc @jdonszelmann, @JonathanBrouwer Some changes occurred in compiler/rustc_passes/src/check_attr.rs |
deprecated attribute checking
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
||
| /// Context of an associated const or associated type (not methods; see [`MethodKind`]). | ||
| #[derive(Copy, Clone, PartialEq, Debug, Eq, StableHash)] | ||
| pub enum AssocKind { |
There was a problem hiding this comment.
Can we reuse the existing AssocCtxt type rather than introducing a new one?
There was a problem hiding this comment.
I reused the existing type.
| let attr_span = cx.attr_span; | ||
| cx.emit_lint( | ||
| UNUSED_ATTRIBUTES, | ||
| DeprecatedAnnotationHasNoEffect { span: attr_span }, |
There was a problem hiding this comment.
Does this need to be its own diagnostic rather than just the default Policy::Warn diagnostic?
There was a problem hiding this comment.
I think using UNUSED_ATTRIBUTES is better here because it's indicates that the attribute "has no effect" rather than saying it has a "wrong target" which is a better fit for unused attributes and unused lint group.
| let attr_span = cx.attr_span; | ||
| cx.emit_lint( | ||
| UNUSED_ATTRIBUTES, | ||
| DeprecatedAnnotationHasNoEffect { span: attr_span }, |
There was a problem hiding this comment.
Is this path covered by any tests?
There was a problem hiding this comment.
here in tests/ui/deprecation/deprecation-sanity.rs:
#[deprecated = "hello"] //~ ERROR attribute cannot be used on
//~| WARN previously accepted
impl Default for X {
fn default() -> Self {
X
}
}|
Reminder, once the PR becomes ready for a review, use |
This comment has been minimized.
This comment has been minimized.
aaa1340 to
111bef3
Compare
|
Some changes occurred in compiler/rustc_attr_ir |
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Updates #153101
r? @JonathanBrouwer